package org.su.webadapter.bind;


import org.su.generalmvc.IEditor;
import org.su.generalmvc.jdbc.DaoFactory;
import org.su.generalmvc.jdbc.IDao;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.lang.reflect.Method;


public class DAOEditor implements IEditor {

	public Object getParamValue(String paramName, Class<?> paramType, int paramIndex, Method writer, ServletRequest request,
								ServletResponse response) {
		
		
		if (DaoFactory.forceCloseDao()) {
			throw new RuntimeException("has not close dao");
		}
		//logger.info(this.method+" bigen dao");
		IDao dao = DaoFactory.createDao();
		
		request.setAttribute(IDao.DAO_KEY, dao);
		
		return dao;
	}

	
	
}
